#pragma once
#include <windows.h>

namespace CppWinApi::Windows
{
    // RAII 封装事件句柄
    class EventHandle
    {
        HANDLE mHandle;

    public:
        explicit EventHandle(HANDLE h = nullptr) : mHandle(h) {}
        ~EventHandle()
        {
            if (mHandle != nullptr)
            {
                CloseHandle(mHandle);
            }
        }
        // 禁用拷贝（避免双重关闭）
        EventHandle(const EventHandle &) = delete;
        EventHandle &operator=(const EventHandle &) = delete;
        // 支持移动语义
        EventHandle(EventHandle &&other) noexcept : mHandle(other.mHandle)
        {
            other.mHandle = nullptr;
        }
        operator HANDLE() const { return mHandle; }
    };
}